<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// 
//  jump.php
//  www.6block.com
//  
//  Created by WillLee on 2011-06-23.
//  Copyright 2011 lishuzu. All rights reserved.
// 

class Jump extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		$this->userinfo = $this->session->userdata('userinfo');
	}
	
	public function index()
	{
		$param = $this->input->get('param');
		if ($param) {
			$param = json_decode(base64_decode($param), true);
		}else{
			showmessage('对不起 跳转出现问题了 我们正在努力修复。', base_url(), '2');			
		}

		foreach ($param as $key => $value) {
			if (!in_array($key, array('key', 'url'))) {
				$key_str .= $value;
			}
		}
		
		$key = md5($key_str.$this->config->item('encryption_key'));
		if ($param['key'] != $key) {
			showmessage('对不起 跳转出现问题了 我们正在努力修复。', base_url(), '2');
		}
		
		if ($param['aid']) {
			$aid = intval($param['aid']);
			if ($aid) {
				$this->db->query("UPDATE ".$this->db->dbprefix('activity')." SET jumpnum = jumpnum + 1 WHERE aid='".$aid."'");
			}

		}
		if ($param['gid']) {
			$gid = intval($param['gid']);
			if ($gid) {
				$this->db->query("UPDATE ".$this->db->dbprefix('goods')." SET jumpnum = jumpnum + 1 WHERE gid='".$gid."'");
			}
		}
		showmessage('正在为您跳转中，请稍等...', $param['url'], 1);
		var_dump($param);
	}
}

/* End of file jump.php */
/* Location: ./application/controllers/welcome.php */